<head>
	<title></title>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<link href="../../css/dialog.css" rel="stylesheet">

	<link href="../../css/skin/Content/Shop/css/public.css?version=20180504" rel="stylesheet" />
	<link href="../../css/skin/Content/Shop/css/style.css?version=20180517" rel="stylesheet" />
	<script src="../../js/JScripts/Shop/jquery-1.11.0.min.js" type="text/javascript"></script>
	<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<script src="../../js/lib/jquery/jquery-1.9.0.min.js"></script>
	<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
	<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js?version=20180420" type="text/javascript"></script>
	<script src="../../js/JS/layout.js" type="text/javascript"></script>
	<script src="../../js/dialog.js"></script>
	<script src="../../js/constants.js" type="text/javascript"></script>
	<script src="../../js/api.js" type="text/javascript"></script>
	<script src="../../js/echarts.min.js" type="text/javascript"></script>

</head>
<script>
	function doMain() {
		window.location.href = 'Add.html';
	}
	var user = $api.getStorage("user");
	var token = $api.getStorage("token");

	function initData() {

		var url = BaseUrl + "Statistics?token=" + $api.getStorage("token");
		$api.ajaxget(url, {}, function(data) { 
			var index= data.Store.Fhaoend.indexOf("T")
			var FendDate =  data.Store.Fhaoend.substr(0,index);
			$("#Endtime").text("好店到期日:" +FendDate );
			$("#Fname").text(data.Store.Ftitle);
			$("#logo").attr("src", data.Store.Flogo);
			//新增会员
			$("#DayBuyerNum").text(data.Day_mnum);
			$("#NoteNum").text(data.Day_salenum);
			$("#DayPayMoney").text($api.toMoney(data.Day_money));
			//总金额
			$("#Member").text(data.Total_mnum);
			$("#WechatPay").text(data.Total_salenum);
			$("#PayMoney").text(data.Total_money);

			//
			$("#Saleing").text(data.Product_saleing_num);
			$("#PreUp").text(data.Product_down_sale_num);
			$("#DeliveryNum").text(data.Sale_sending_num);

			if(data.Rows && data.Rows.length > 0) {
				FillUser(data.Rows);
			}
		});

	}

	function FillUser(rows) {
		var dom = document.getElementById("app_user_list");
		var myChart = echarts.init(dom);
		var x = [];
		var y = [];
		for(var i in rows) {
			var row = rows[i];
			x.push(row.Fmonth + "-" + row.Fday);
			y.push(row.Fnum);
		}
		var app = {};
		option = null;
		option = {
			xAxis: {
				type: 'category',
				boundaryGap: false,
				data: x
			},
			yAxis: {
				type: 'value'
			},
			series: [{
				data: y,
				type: 'line',
				areaStyle: {}
			}]
		};;
		if(option && typeof option === "object") {
			myChart.setOption(option, true);
		}
	}

	function FillSaleDay(rows) {
		if(!rows || rows.length == 0) return;

		var x = [];
		var y1 = [];
		var y2 = [];
		for(var i in rows) {
			var row = rows[i];
			x.push(row.M + "-" + row.D);
			y1.push(row.FsaleMoney);
			y2.push(row.Fnum);
		}

		var dom = document.getElementById("app_sale_list");
		var myChart = echarts.init(dom);
		var app = {};
		option = null;
		var posList = [
			'left', 'right', 'top', 'bottom',
			'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
		];

		app.configParameters = {
			rotate: {
				min: -90,
				max: 90
			},
			align: {
				options: {
					left: 'left',
					center: 'center',
					right: 'right'
				}
			},
			verticalAlign: {
				options: {
					top: 'top',
					middle: 'middle',
					bottom: 'bottom'
				}
			},
			position: {
				options: echarts.util.reduce(posList, function(map, pos) {
					map[pos] = pos;
					return map;
				}, {})
			},
			distance: {
				min: 0,
				max: 100
			}
		};

		app.config = {
			rotate: 90,
			align: 'left',
			verticalAlign: 'middle',
			position: 'insideBottom',
			distance: 15,
			onChange: function() {
				var labelOption = {
					normal: {
						rotate: app.config.rotate,
						align: app.config.align,
						verticalAlign: app.config.verticalAlign,
						position: app.config.position,
						distance: app.config.distance
					}
				};
				myChart.setOption({
					series: [{
						label: labelOption
					}, {
						label: labelOption
					}]
				});
			}
		};

		var labelOption = {
			show: true,
			position: app.config.position,
			distance: app.config.distance,
			align: app.config.align,
			verticalAlign: app.config.verticalAlign,
			rotate: app.config.rotate,
			formatter: '{c}  {name|{a}}',
			fontSize: 16,
			rich: {
				name: {
					textBorderColor: '#fff'
				}
			}
		};

		option = {
			color: ['#003366', '#e5323e'],
			tooltip: {
				trigger: 'axis',
				axisPointer: {
					type: 'shadow'
				}
			},
			legend: {
				data: ['交易额', '成交数']
			},
			toolbox: {
				show: true,
				orient: 'vertical',
				left: 'right',
				top: 'center',
				feature: {
					mark: {
						show: false
					},
					dataView: {
						show: false,
						readOnly: false
					},
					magicType: {
						show: false,
						type: ['line', 'bar', 'stack', 'tiled']
					},
					restore: {
						show: false
					},
					saveAsImage: {
						show: false
					}
				}
			},
			xAxis: [{
				type: 'category',
				axisTick: {
					show: false
				},
				data: x
			}],
			yAxis: [{
				type: 'value'
			}],
			series: [{
					name: '交易额',
					type: 'bar',
					barGap: 0,
					label: labelOption,
					data: y1
				},
				{
					name: '成交数',
					type: 'bar',
					label: labelOption,
					data: y2
				}
			]
		};;
		if(option && typeof option === "object") {
			myChart.setOption(option, true);
		}
	}

	function FillSaleMonth(rows) {
		if(!rows || rows.length == 0) return;

		var x = [];
		var y1 = [];
		var y2 = [];
		for(var i in rows) {
			var row = rows[i];
			x.push(row.Y + "/" + row.M);
			y1.push(row.FsaleMoney);
			y2.push(row.Fnum);
		}

		var dom = document.getElementById("app_sale_month_list");
		var myChart = echarts.init(dom);
		var app = {};
		option = null;
		var posList = [
			'left', 'right', 'top', 'bottom',
			'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
		];

		app.configParameters = {
			rotate: {
				min: -90,
				max: 90
			},
			align: {
				options: {
					left: 'left',
					center: 'center',
					right: 'right'
				}
			},
			verticalAlign: {
				options: {
					top: 'top',
					middle: 'middle',
					bottom: 'bottom'
				}
			},
			position: {
				options: echarts.util.reduce(posList, function(map, pos) {
					map[pos] = pos;
					return map;
				}, {})
			},
			distance: {
				min: 0,
				max: 100
			}
		};

		app.config = {
			rotate: 90,
			align: 'left',
			verticalAlign: 'middle',
			position: 'insideBottom',
			distance: 15,
			onChange: function() {
				var labelOption = {
					normal: {
						rotate: app.config.rotate,
						align: app.config.align,
						verticalAlign: app.config.verticalAlign,
						position: app.config.position,
						distance: app.config.distance
					}
				};
				myChart.setOption({
					series: [{
						label: labelOption
					}, {
						label: labelOption
					}]
				});
			}
		};

		var labelOption = {
			show: true,
			position: app.config.position,
			distance: app.config.distance,
			align: app.config.align,
			verticalAlign: app.config.verticalAlign,
			rotate: app.config.rotate,
			formatter: '{c}  {name|{a}}',
			fontSize: 16,
			rich: {
				name: {
					textBorderColor: '#fff'
				}
			}
		};

		option = {
			color: ['#003366', '#e5323e'],
			tooltip: {
				trigger: 'axis',
				axisPointer: {
					type: 'shadow'
				}
			},
			legend: {
				data: ['交易额', '成交数']
			},
			toolbox: {
				show: true,
				orient: 'vertical',
				left: 'right',
				top: 'center',
				feature: {
					mark: {
						show: false
					},
					dataView: {
						show: false,
						readOnly: false
					},
					magicType: {
						show: false,
						type: ['bar']
					},
					restore: {
						show: false
					},
					saveAsImage: {
						show: false
					}
				}
			},
			xAxis: [{
				type: 'category',
				axisTick: {
					show: false
				},
				data: x
			}],
			yAxis: [{
				type: 'value'
			}],
			series: [{
					name: '交易额',
					type: 'bar',
					barGap: 0,
					label: labelOption,
					data: y1
				},
				{
					name: '成交数',
					type: 'bar',
					label: labelOption,
					data: y2
				}
			]
		};;
		if(option && typeof option === "object") {
			myChart.setOption(option, true);
		}
	}

	function initbank() {
		var url = BaseUrl + "StatisticsBank?token=" + $api.getStorage("token") + "&Fstatus=2";
		$api.ajaxget(url, {}, function(res) {
			if(res.Code == 0) {
				FillSaleMonth(res.Rows);
				FillSaleDay(res.DayRows);
			}

		});
	}

	$(function() {
		if($api.isEmpty(token)) {
			parent.logout();
		}
		initData();
		initbank();

	});
	
	function doInfo(title,url){
			parent.f_addTab(-1, title, url);
	}
</script>

<body class="mainbody">
	<form id="form1">

		<div class="main">
			<div class="In_shop">
				<div class="clearfix In_shop_d">
					<div class="fl In_shopLeft"><img  style="width: 79px;height: 79px;cursor:pointer" id="logo" src="../../css/skin/Content/Shop/images/logo.png"></div>
					<div class="fl flIn_shopRight">
						<div id="Fname" style="font-size: 22px;margin-top: 10px;cursor:pointer;">杭州互动软件有限公司</div>
						<div class="In_shopRight_b clearfix" style="clear:both;">
							<!--<p><span id="Endtime">小程序到期日：2020-10-12</span></p>-->

						</div>
					</div>
				</div>

			</div>
			<!--常用功能-->
			 
			<div class="Common">
				<h3><i class="CommonIcont05"></i>今日数据</h3>
				<ul class="clearfix goodsList">
					<li>
						<a  onclick="doInfo('会员管理','../vstore/tb_store_app_user/List.html')" >
							<i class="icon15"></i>
							<p><span id="DayBuyerNum">0</span>新增会员</p>
						</a>
					</li>
					 
					<li>
						<a   onclick="doInfo('订单管理','../vstore/tb_sale/List.html?status=2')" >
							<i class="icon17"></i>
							<p><span id="NoteNum">0</span>今日订单</p>
						</a>
					</li>
					<li>
						<a  onclick="doInfo('订单管理','../vstore/tb_sale/List.html')">
							<i class="icon16"></i>
							<p><span id="DayPayMoney">0.00</span>销售金额</p>
						</a>
					</li>
					<!--
					<li>
						<i class="icon18"></i>
						<p><span id="DayBs">0</span>今日访问量</p>
					</li>-->
				</ul>
			</div>
			<!--商品一览-->
			<div class="Common">
				<h3><i class="CommonIcont02"></i>商品一览</h3>

				<ul class="clearfix goodsList">

					<li>
						<a  onclick="doInfo('销售中的商品','../vstore/tb_product/List.html?status=1')">
							<i class="icon10"></i>
							<p><span id="Saleing">0</span>销售中</p>
						</a>
					</li>

					<li>
						<a  onclick="doInfo('待上架商品','../vstore/tb_product/List.html?status=0')">
							<i class="icon13"></i>
							<p><span id="PreUp">0</span>待上架</p>
						</a>
					</li>
					<li>
						<a   onclick="doInfo('待发货','../vstore/tb_sale/List.html?status=2')">
							<i class="icon09"></i>
							<p><span id="DeliveryNum">0</span>待发货</p>
						</a>
					</li>

				</ul>
			</div>
			<div class="Common">
				<h3><i class="CommonIcont02"></i>数据统计</h3>
				<div style="float: left;width: 33%;text-align: center;">
					<div id="app_user_list" style="height: 300px"></div>
					<a href="../tb_store_app_user/List.html">
						<p>近7日用户变化</p>
					</a>
				</div>
				<div style="float: left;width: 33%;text-align: center;">
					<div id="app_sale_list" style="height: 300px"></div>
					<a href="../tb_sale/List.html">
						<p>近7日交易额</p>
					</a>
				</div>
				<div style="float: left;width: 33%;text-align: center;">
					<div id="app_sale_month_list" style="height: 300px"></div>
					<a href="../tb_sale/List.html">
						<p>近6个月交易额</p>
					</a>
				</div>

			</div>

			<div class="clearfix Effect">
				<!--商品一览-->
				<div class="fl Effect_w">
					<div class="Common">
						<h3><i class="CommonIcont03"></i>店铺整体效果分析</h3>
						<ul class="Effect_u clearfix">
							<li class="Effect_u1">
								<i></i>
								<a  >
									<p>总会员数</p>
									<span id="Member">0</span>
								</a>
							</li>
							<li class="Effect_u2">
								<i></i>
								<a  >
									<p>总订单数</p>
									<span id="WechatPay">0</span>
								</a>
							</li>
							<li class="Effect_u3">
								<i></i>
								<a  >
									<p>总交易额</p>
									<span id="PayMoney">0</span>
								</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>

	</form>
</body>

</html>